﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using Manager;
using UnityEngine.SceneManagement;

public class SceneMediator:MediatorBase
{
    [Inject]
    public SceneView view;

    [Inject]
    public SceneModel model;

    public override void Initialize()
    {
        base.Initialize();
        AddContextListener<NotifyEvent>(NotifyEvent.Type.LoadRemoteFileComplete, onLoadRemoteFileComplete);
    }

    private void onLoadRemoteFileComplete(NotifyEvent e)
    {
        Debug.LogError(e.ToString());
        LoadScene("WinterScene", Vector3.zero);
    }

    /// <summary>
    /// 加载场景
    /// </summary>
    /// <param name="sceneName"></param>
    /// <param name="defaultPos"></param>
    private void LoadScene(string sceneName,Vector3 defaultPos)
    {
        Debug.LogError("准备进入场景:" + sceneName + "...");
        //初始化主角的代码暂时放这
        SceneHeroVo vo = new SceneHeroVo();
        vo.rickName = "测试主角";
        //vo.assetbundleName = "TestAvatar";
		//vo.assetbundleName = "barbarian_player";
        vo.assetbundleName = "stoneking";
        SceneHero.CreateHero(vo);


        SceneActorVo actorVo = new SceneActorVo();
        actorVo.rickName = "测试怪";
        actorVo.assetbundleName = "TestAvatar";
        //actorVo.assetbundleName = "stoneking";
        SceneTestActor.CreateTest(actorVo);

        view.LoadScene(sceneName,defaultPos);
    }

}
